#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	float faHeight, moHeight, chn;
	char sex, sports, diet;
	scanf("%c %c %c %f %f", &sex, &sports, &diet, &faHeight, &moHeight);
	if (sex == 'F')
	{
		if (sports == 'Y' && diet == 'Y')
		{
			chn = (faHeight + moHeight) / 2 + ((faHeight + moHeight) / 2) * 0.02 + ((faHeight + moHeight) / 2) * 0.015;
			printf("%6.2f", chn);
		}
		else if (sports == 'N' && diet == 'Y')
		{
			chn = (faHeight + moHeight) / 2 + ((faHeight + moHeight) / 2) * 0.015;
			printf("%6.2f", chn);
		}
		else if (sports == 'Y' && diet == 'N')
		{
			chn = (faHeight + moHeight) / 2 + ((faHeight + moHeight) / 2) * 0.02;
			printf("%6.2f", chn);
		}
		else if (sports == 'N' && diet == 'N')
		{
			chn = (faHeight + moHeight) / 2;
			printf("%6.2f", chn);
		}

	}


	else if (sex == 'M')
	{
		if (sports == 'Y' && diet == 'Y')
		{
			chn = (faHeight + moHeight) * 0.54 + ((faHeight + moHeight) * 0.54) * 0.02 + ((faHeight + moHeight) * 0.54) * 0.015;
			printf("%6.2f", chn);
		}
		else if (sports == 'N' && diet == 'Y')
		{
			chn = (faHeight + moHeight) * 0.54 + ((faHeight + moHeight) * 0.54) * 0.015;
			printf("%6.2f", chn);
		}
		else if (sports == 'Y' && diet == 'N')
		{
			chn = (faHeight + moHeight) * 0.54 + ((faHeight + moHeight) * 0.54) * 0.02;
			printf("%6.2f", chn);
		}
		else if (sports == 'N' && diet == 'N')
		{
			chn = (faHeight + moHeight) * 0.54;
			printf("%6.2f", chn);
		}

	}
	return 0;
}
